/**
 * 作者:李杰
 * email: maillijie@gmail.com
 */
package com.javainfo.service;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;

import com.javainfo.dao.ConditionMap;
import com.javainfo.dao.inf.BaseDaoIf;
import com.javainfo.service.inf.BaseServiceIf;
import com.javainfo.util.EntityConvertUtil;

public abstract class BaseService<T> implements BaseServiceIf<T>{
	
	private EntityConvertUtil convertUtil;
	
	public void add(T obj) {
		getBaseDao().add(obj);
	}

	public void addAll(Collection<T> objs) {
		getBaseDao().addAll(objs);
	}

	public void delete(T obj) {
		getBaseDao().delete(obj);
	}

	public void deleteAll(Collection<T> list) {
		getBaseDao().deleteAll(list);
	}

	public List<T> getAll() {
		return getBaseDao().getAll();
	}

	public List<T> getByConditions(Collection<ConditionMap> conditions)
			throws InstantiationException, IllegalAccessException,
			SecurityException, NoSuchMethodException, IllegalArgumentException,
			InvocationTargetException {
		return getBaseDao().getByConditions(conditions);
	}

	public T getById(int id) {
		return getBaseDao().getById(id);
	}

	public List<T> getByPage(int start, int limit)
			throws InstantiationException, IllegalAccessException {
		return getBaseDao().getByPage(start, limit);
	}

	public List<T> getByTemp(T t) {
		return getBaseDao().getByTemp(t);
	}

	public int getListSize() {
		return getBaseDao().getListSize();
	}

	public List<T> pageByConditions(T t, int start, int limit)
			throws InstantiationException, IllegalAccessException {
		return getBaseDao().pageByConditions(t, start, limit);
	}

	public void update(T obj) {
		getBaseDao().update(obj);
	}

	public void updateAll(Collection<T> objs) {
		getBaseDao().updateAll(objs);
	}

	public abstract BaseDaoIf<T> getBaseDao();

	/**
	 * @param convertUtil the convertUtil to set
	 */
	public void setConvertUtil(EntityConvertUtil convertUtil) {
		this.convertUtil = convertUtil;
	}

	/**
	 * @return the convertUtil
	 */
	public EntityConvertUtil getConvertUtil() {
		return convertUtil;
	}
	
	
}